<?xml version="1.0"?>
<yandex>
<!-- 集群配置 -->
<clickhouse_remote_servers>
  <{{ ck_cluster_name }}> <!-- 集群名字，自定义 -->

{# 处理所有share_前缀的变量 #}
{% for var_name in vars | select('match', '^share_') | sort %}
  {# 安全分割字符串并过滤空值 #}
  {% set items = vars[var_name].split(',') | map('trim') | list %}
  <shard> <!-- 定义分片1 -->
            <weight>1</weight>
            <!-- 多副本的话这里要设置为true，否则各个副本内数据可能不一致 -->
            <internal_replication>true</internal_replication>
  {# 非空检查 #}
  {% if items %}
       {% for item in items %}
            <replica> 
                <host>{{ item }}</host>
                <port>{{ ck_port }}</port>
                <user>default</user>
                <password>{{ ck_password }}</password>
            </replica>
       {% endfor %}
  {% endif %}
  </shard>
{% endfor %}
  </{{ ck_cluster_name }}>
</clickhouse_remote_servers>

<zookeeper-servers>
  {% set items = ck_with_zk.split(',') | map('trim') | list %}
{% for item in items %}
  <node index="{{ loop.index }}">
    <host>{{ item }}</host>
    <port>{{ zk_port }}</port>
  </node>
{% endfor %}
    <session_timeout_ms>600000</session_timeout_ms>
    <operation_timeout_ms>300000</operation_timeout_ms>
</zookeeper-servers>
<!-- 数据压缩算法  -->
<clickhouse_compression>
   <case>
      <min_part_size>10000000000</min_part_size> 
      <min_part_size_ratio>0.01</min_part_size_ratio>
      <method>lz4</method>
   </case>
</clickhouse_compression>

</yandex>
